#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include <QMenu>
#include <QSystemTrayIcon>
#include <QCloseEvent>
#include"src/page0.h"   //我的设备
#include"src/page2.h"   //点检看板
#include"src/importwidget.h"    //设备导入
#include"src/page1.h"   //设备领用
#include"src/page3.h"   //设备查询
#include"src/repairwidget.h"    //设备维修
#include"src/page4.h"   //设备报废
#include"src/verwidget.h"   //设备校验
#include"src/adminwidget.h" //后台管理

namespace Ui {
class MainWindow;
}

class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    explicit MainWindow(QWidget *parent = nullptr);
    ~MainWindow();

//    void enterEvent(QEvent*);
//    void leaveEvent(QEvent*);

private slots:
    void changeToLogin();
    void changeWidget(int index,QString s);

    void iconIsActived(QSystemTrayIcon::ActivationReason reason);

protected:
    void closeEvent(QCloseEvent *event);

private:
    Ui::MainWindow *ui;

    enum{
      ADMIN=0b1000,
      MANAGER=0b0100,
      GROUPER=0b0010,
      WORDER=0b0001
    };
    int constRole=WORDER;

    void initNav();
    bool firstLogin=false;

    int getRole();

//    QTimer *tChangeFirst;

    Page0 *p0;
    Page2 *p2;
    ImportWidget *importWidget;
    Page1 *p1;
    Page3 *p3;
    RepairWidget *repairWidget;
    Page4 *p4;
//    VerWidget *verWidget;
    AdminWidget *adminWidget;

    QAction *changeAccount;
    QAction *quitPAction;
    QMenu *pMenu;

    QSystemTrayIcon *systemTray;
    QMenu *myMenu;
    QAction *restoreWinAction;
    QAction *quitAction;
    QAction *hideAction;
    QAction *changeAction;

    QList<QWidget*> widgetList={p0,p2,p1,p3,repairWidget,p4,adminWidget,importWidget};
};

#endif // MAINWINDOW_H
